package ar.uba.fi.tonyvaliente.persistors;

import java.nio.ByteBuffer;

import ar.uba.fi.tonyvaliente.files.Persistor;
import ar.uba.fi.tonyvaliente.files.PersistorException;

public class IntegerPersistor extends Persistor<Integer> {

	public IntegerPersistor() {
	}

	public Integer deserialize(byte[] bytes) throws PersistorException {
		ByteBuffer buffer = ByteBuffer.wrap(bytes);
		return buffer.getInt();
	}

	public byte[] serialize(Integer t) throws PersistorException {
		byte b[] = new byte[4];
		ByteBuffer buffer = ByteBuffer.wrap(b);
		buffer.putInt(t.intValue());
		return b;
	}
}
